package com.example.demo.controller;

import com.example.demo.config.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/home")
public class HomeController {
    private final Student student1;
    @Autowired
    private Environment environment;

    @Autowired
    public HomeController(Student _student1) {
        this.student1 = _student1;
    }

    @GetMapping("/hello")
    public String hello() {
//        Student s = new Student();
//        s.setAge("123");
//        String age = s.getAge();
        return "Hello world!";
    }

    @GetMapping("/getvalue")
    public String getvalue() {
        return student1.getName();
    }

    @GetMapping("/getvalue2")
    public String getvalue3() {
        return environment.getProperty("person.name");
    }

    //@ResponseBody
    @RequestMapping("/test")
    public String test() {
        return "2";
    }
}
